using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Media3D;

using _3DTools;

//using IdentityMine.Windows.Essentials;

namespace SBPweb.MediaCenter.Tools.WPF.Generators
{
    /*
    /// <summary>
    /// This model generates InteractiveVisual3D objects for each item.
    /// </summary>
    public class InteractiveVisual3DModelGenerator : ModelGeneratorBase
    {
        #region dependency properties

        #region DefaultGeometry

        public Geometry3D DefaultGeometry
        {
            get { return (Geometry3D)GetValue(GeometryProperty); }
            set { SetValue(GeometryProperty, value); }
        }

        public static readonly DependencyProperty GeometryProperty =
            DependencyProperty.Register("DefaultGeometry", typeof(Geometry3D), typeof(InteractiveVisual3DModelGenerator), 
            new UIPropertyMetadata(null, new PropertyChangedCallback(OnDefaultGeometryChanged)));

        private static void OnDefaultGeometryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((InteractiveVisual3DModelGenerator)d).OnDefaultGeometryChanged();
        }

        #endregion

        #region ItemModelTransform

        public Transform3D ItemModelTransform
        {
            get { return (Transform3D)GetValue(ItemModelTransformProperty); }
            set { SetValue(ItemModelTransformProperty, value); }
        }

        public static readonly DependencyProperty ItemModelTransformProperty =
            DependencyProperty.Register("ItemModelTransform", typeof(Transform3D), typeof(InteractiveVisual3DModelGenerator),
            new UIPropertyMetadata(null, new PropertyChangedCallback(OnItemModelTransformChanged)));

        private static void OnItemModelTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((InteractiveVisual3DModelGenerator)d).RaiseRegenerationRequired();
        }

        #endregion

        #endregion

        #region methods

        #region public

        public override object GetItemModel(object item)
        {
            if (this.DefaultGeometry == null)
            {
                throw new InvalidOperationException("Geometry must be set before models can be generated.");
            }

            InteractiveVisual3D interactiveViz3d = new InteractiveVisual3D();
            interactiveViz3d.Geometry = this.DefaultGeometry;

            if (this.ItemModelTransform != null)
            {
                interactiveViz3d.Transform = this.ItemModelTransform;
            }

            if (item is System.Windows.Media.Visual)
            {
                DependencyObject parent = VisualTreeHelper.GetParent((System.Windows.Media.Visual)item);

                if (parent is AdornerDecorator)
                {
                    //unparent the child
                    ((AdornerDecorator)parent).Child = null;
                }

                interactiveViz3d.Visual = (System.Windows.Media.Visual)item;
            }

            return interactiveViz3d;
        }

        #endregion

        #region private

        private void OnDefaultGeometryChanged()
        {
            base.RaiseRegenerationRequired();
        }

        #endregion

        #endregion

        #region events

        #region public
        #endregion

        #region private
        #endregion

        #region protected
        #endregion

        #region internal
        #endregion

        #endregion

        #region constants

        #endregion

        #region fields

        #endregion
    }
    */
}
